<?php
/** 
 * $Source: /cvsroot/pn-commerce/pn-commerce/pntemplates/plugins/function.pnLimitLength.php,v $
 * $Author: klavs $
 * $Revision: 1.1 $
 * $Date: 2004/02/29 16:02:06 $
 *
 * Type: Function
 *
 * Purpose:  
 * @param length integer, the max length of the returned string
 * @param string string, the string to limit to length
 * @return string, the length limited string
 */
function smarty_function_pnLimitLength($params, &$smarty)
{
    extract($params); 
	
    if (!isset($length) || !isset($string)) {
        $smarty->trigger_error("pncusermodurl: attribute length and string required");
        return false;
    }    

    $newstring = substr( $string, 0, $length );
    if( strlen( $string) > $length )
		$newstring = $newstring . "...";
    
    return $newstring;
}
?>
